import java.net.InetAddress;
import java.io.Serializable;
import java.sql.*;
public class Request implements Serializable{
	int templatechoice;
	Object[] args;
    User requestgiver;
    
   /*
    choice 1 :@none    Creates table Users
    choice 2 :@none    Creates table Cars
    choice 3 :@none    Creates table Stats
    choice 4 :@UID     Select * from Users where UID == @arg0
    choice 5 :@none    Creates table CH_Data
    choice 6 :@f,l,uid,pass,salt,type,CH_ID, Integer NUMVEHICLES
    "INSERT INTO USERS (FIRSTNAME, LASTNAME, UID, PASSWORD, SALT, USERTYPE, CH_ID, NUMVEHICLES) VALUES (?,?,?,?,?,?,?,?)"
    choice 7 :@UID     Select * from Cars where User = @arg0
    choice 8 :@make, model, year, vin, Username, CHID
    "INSERT INTO CARS (MAKE, MODEL, YEAR, VIN, USER, CH_ID) VALUES(?, ?, ?, ?, ?, ?)"
    choice 9 :@UID     Numvehicles is incremented
    choice 10:@VIN     Select * from Stats where car = VIN
    choice 11:@newUID,hash, olduid 
    "UPDATE USERS SET UID = ?,PASSWORD = ? WHERE UID = ?"
    choice 12:@newuid, olduid 
    "UPDATE CARS SET USER = ? WHERE USER = ?"
    choice 13:@ch_id   "SELECT * FROM CARS WHERE CH_ID = @arg0
    choice 14:@vin     "SELECT * FROM CLEARINGHOUSE WHERE VIN = ? "
    choice 15:@vin     "DELETE FROM CLEARINGHOUSE WHERE VIN = '"+vin+"'"
    choice 16:@vin,date 
    "DELETE FROM CLEARINGHOUSE WHERE VIN = '"+currCar.vin+"' AND DATE_TIME = '"+slot+"'"
    choice 17:@vin     "DELETE FROM CARS WHERE VIN = ?"
    choice 18:@UID     "UPDATE USERS SET NUMVEHICLES = NUMVEHICLES-1 WHERE UID = ?"
    choice 19:@vin, date
    "SELECT * FROM STATS WHERE VIN = ? ORDER BY 'DATE_TIME' ASC"
    choice 20:@vin      "SELECT * FROM STATS WHERE VIN = ? ORDER BY 'ORDER_NUM' ASC"
    */    
    public Request(){
        
    }
    public Request(int arg, Object[] fillers, User me){
        args = fillers;
        templatechoice = arg;
        requestgiver = me;
    }
   public Request(int choice, int numargs, User me){
      templatechoice = choice;
      args = new Object[numargs];   
      requestgiver = me;
   }
    //Object contains the proposed arguments to a MYSQL Prepared Statement
    public Object[] getArgs(){
        return args;
    }
    //choice dictionary is found in Server.job class
    public int getChoice(){
        return templatechoice;
    }
    public User getUser(){
        return requestgiver;
    }
    public void setString(int index, String into){
        try{
            args[index] = into;
        }
        catch(Exception f){
           System.out.println("COuldnt pass String to args array");
        }
    }
    public void setInt(int index, int into){
        try{
            args[index] = new Integer(into);
        }
        catch(Exception f){
           System.out.println("Couldn't pass String to args array");
        }
    }
   public Response executeQuery(){
      Response toret = AutoBiography.client.getResponse(this);
  //    ClientModel.getResponse(new Request(templatechoice, args, requestgiver));
      return toret;
   }
   public void execute(){
      Response toret = AutoBiography.client.getResponse(this);
   }
   public void executeUpdate(){
      Response toret = AutoBiography.client.getResponse(this);
   }
}
